package com.atguigu.gulimall.order.web;

import com.atguigu.gulimall.order.annotation.RateLimiter;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.springframework.cloud.commons.util.IdUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author lhj
 * @Date 2024/5/23 21:57
 */
@RestController
public class LimiterController {
    
    @RateLimiter(key = "limit", permitsPerSeconds = 2, expire = 5,  message = "访问过于频繁，请稍后再试", isOpen = true)
    @GetMapping("/order/order/limit")
    public String limit() {
        String uuid = IdWorker.get32UUID();
        return "下单成功，订单号为：" + uuid;
    }
}
